import * as TYPES from '../action-types';

let INIT_STATE = {
    candidateData: {
        data: []
    }
};
export default function candidate(state = INIT_STATE, action) {
    state = JSON.parse(JSON.stringify(state));
    let result = {};
    switch (action.type) {
        case TYPES.CANDIDATE_QUERY_LIST:
            result = action.result;
            if (parseFloat(result.code) === 0) {
                state.candidateData.data = result.data;
            }
            break;
        case TYPES.CANDIDATE_ADD_TO_LIST:
            result = action.result;
            if (parseFloat(result.code) === 0) {
                state.candidateData.data.shift(result.data);
            }
            break;
    }
    return state;
};